/*
 * Copyright (c) 2005, 2014 vacoor
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package org.vacoor.nothing.misc.sap.jco.config;

import com.sap.conn.jco.ext.DestinationDataEventListener;
import com.sap.conn.jco.ext.DestinationDataProvider;

import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 使用 Properties 配置
 * 配置说明具体见 {@link ClassPathConfigDestinationDataProvider}
 *
 * @author vacoor
 */
class PropertiesConfigDestinatioinDataProvider implements DestinationDataProvider {
    private Map<String, Properties> props = new ConcurrentHashMap<String, Properties>();

    public void addDestination(String destinationName, Properties properties) {
        if (destinationName != null && properties != null) {
            props.put(destinationName, properties);
        }
    }

    public void removeDestination(String destinationName) {
        props.remove(destinationName);
    }

    @Override
    public Properties getDestinationProperties(String destinationName) {
        return props.get(destinationName);
    }

    @Override
    public boolean supportsEvents() {
        return false;
    }

    @Override
    public void setDestinationDataEventListener(DestinationDataEventListener destinationDataEventListener) {
        // unsupported
    }
}
